Repository navigation
feat(cli): add projects setup command - #4356
Conversation
Adopt an existing v2 project on a target host without creating a new one — the dedup counterpart to `projects create`. Mirrors the desktop's two-button UX: `create` makes a fresh cloud project, `setup <id>` attaches an existing one to the host (clone the cloud-stored URL or register an existing folder). Bumps cli to 0.2.14.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds a new CLI command for adopting existing projects onto a specified host in either clone or import mode, with validation of mutually exclusive options. Supporting version updates bump the CLI package and config from 0.2.13 to 0.2.14. ChangesProject Setup Feature
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
Greptile SummaryAdds a
Confidence Score: 4/5Safe to merge; the new command correctly validates its flags, delegates to an existing host-service mutation, and follows established patterns throughout the codebase. The command logic is straightforward and mirrors packages/cli/src/commands/projects/setup/command.ts — the mutex error message ambiguity is worth a second look before shipping user-facing docs.
|
| Filename | Overview |
|---|---|
| packages/cli/src/commands/projects/setup/command.ts | New projects setup command; validation logic is sound but the mutex error message is ambiguous when neither mode flag is provided |
| packages/cli/cli.config.ts | Version bump 0.2.13 → 0.2.14 only |
| packages/cli/package.json | Version bump 0.2.13 → 0.2.14 only |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as superset CLI
participant HT as resolveHostTarget
participant HS as Host Service (tRPC)
participant Cloud as Cloud API
User->>CLI: "superset projects setup <id> --local --import <path>"
CLI->>CLI: validate mutex (--parent-dir XOR --import)
CLI->>CLI: validate --allow-relocate requires --import
CLI->>HT: "requireHostTarget({local: true})"
HT-->>CLI: hostId
CLI->>HT: "resolveHostTarget({hostId, orgId, jwt})"
HT-->>CLI: "ResolvedHostTarget {client, hostId}"
CLI->>HS: "project.setup.mutate({projectId, mode: {kind, repoPath, allowRelocate}})"
HS->>Cloud: "linkRepoCloneUrl (if import & remote found)"
HS-->>CLI: result
CLI-->>User: "Set up project <id> on host <hostId>"
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/cli/src/commands/projects/setup/command.ts:29-34
**Mutex error message fires for "neither provided" case too**
`Boolean(undefined) === Boolean(undefined)` is `true`, so a user who omits both flags sees "Specify exactly one of --parent-dir or --import" — a message that reads as if they supplied both rather than neither. The same pattern exists in `create/command.ts`, but here the lack of a `--clone` analogue makes the two-flag surface smaller and the "neither" case more likely to be hit accidentally. A disambiguated check (or a separate `else if` branch) would make the error clearer to users in the omit-both path.
Reviews (1): Last reviewed commit: "feat(cli): add `projects setup` command" | Re-trigger Greptile
| if (Boolean(options.parentDir) === Boolean(options.import)) { | ||
| throw new CLIError( | ||
| "Specify exactly one of --parent-dir or --import", | ||
| "Use --parent-dir <path> to clone, or --import <path> to register an existing folder", | ||
| ); | ||
| } |
There was a problem hiding this comment.
Mutex error message fires for "neither provided" case too
Boolean(undefined) === Boolean(undefined) is true, so a user who omits both flags sees "Specify exactly one of --parent-dir or --import" — a message that reads as if they supplied both rather than neither. The same pattern exists in create/command.ts, but here the lack of a --clone analogue makes the two-flag surface smaller and the "neither" case more likely to be hit accidentally. A disambiguated check (or a separate else if branch) would make the error clearer to users in the omit-both path.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli/src/commands/projects/setup/command.ts
Line: 29-34
Comment:
**Mutex error message fires for "neither provided" case too**
`Boolean(undefined) === Boolean(undefined)` is `true`, so a user who omits both flags sees "Specify exactly one of --parent-dir or --import" — a message that reads as if they supplied both rather than neither. The same pattern exists in `create/command.ts`, but here the lack of a `--clone` analogue makes the two-flag surface smaller and the "neither" case more likely to be hit accidentally. A disambiguated check (or a separate `else if` branch) would make the error clearer to users in the omit-both path.
How can I resolve this? If you propose a fix, please make it concise.
Summary
Adopt an existing v2 project on a host without creating a duplicate — the dedup counterpart to
projects create. Without this, anyone setting up Superset on a new machine and reaching for the CLI would always create a fresh cloud project, even if their org already has one for the same repo.<id>is the cloud project UUID (find it viasuperset projects list).--parent-dir <path>triggers clone mode — URL comes from the cloud project, so no--clone <url>needed.--import <path>registers an existing folder.--allow-relocatepermits re-importing at a different path when the project is already set up here.Wraps host-service
project.setup, which already handles the no-op-when-already-set-up case and thelinkRepoCloneUrlwrite-back when an imported folder has a remote the cloud project doesn't yet know about.Pairs with
projects createto mirror the desktop's two-button UX (Create vs Import).Bumps cli
0.2.13→0.2.14.Test plan
--helpand validation cases (mutex,--allow-relocaterequires--import)superset projects setup <id> --local --import <path>against a project already set up returned the existingmainWorkspaceId(idempotent)superset projects setup <id> --local --parent-dir <path>clones a fresh checkout for a project withrepoCloneUrlsuperset projects setup <id> --local --import <path>for a project with norepoCloneUrlwrites back vialinkRepoCloneUrlif the folder has a remotesuperset projects setup <id> --host <remote> --parent-dir <path>works against a remote host through the relaySummary by cubic
Add
superset projects setupto attach an existing cloud project to a target host without creating a duplicate. Supports clone or import modes and is idempotent.New Features
superset projects setup <id>targeting--host <id>or--local.--parent-dir <path>, or import with--import <path>;--allow-relocatepermits re-import at a new path.--parent-dir/--import;--allow-relocateonly with--import.project.setup; no-op if already set up and writes back missing repo URL when importing.Dependencies
@superset/clifrom 0.2.13 to 0.2.14.Written for commit 58f2b93. Summary will update on new commits.
Summary by CodeRabbit
New Features
Chores